let value = try!(ConfigValue::from_toml(&path, toml::Table(table)));
try!(cfg.merge(value));
Ok(())
- }).map_err(|_| human("Couldn't load Cargo configuration")));
+ }).chain_error(|| human("Couldn't load Cargo configuration")));
match cfg {
fn walk_tree(pwd: &Path,
walk: |File| -> CargoResult<()>) -> CargoResult<()> {
let mut current = pwd.clone();
- let mut err = false;
loop {
let possible = current.join(".cargo").join("config");
if possible.exists() {
let file = try!(File::open(&possible));
- match walk(file) {
- Err(_) => err = false,
- _ => ()
- }
+ try!(walk(file));
}
-
- if err { return Err(internal("")); }
if !current.pop() { break; }
}
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
})
+
+test!(bad_cargo_config {
+ let foo = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ this is not valid toml
+ "#);
+ assert_that(foo.cargo_process("build").arg("-v"),
+ execs().with_status(101).with_stderr("\
+Couldn't load Cargo configuration
+
+Caused by:
+ could not parse Toml manifest; path=[..]
+
+Caused by:
+ could not parse input TOML
+[..].cargo[..]config:2:20-2:21 expected `=`, but found `i`
+
+"));
+})